﻿using UnityEngine;
using System.Collections;

/// <summary>
/// hikim 140103
/// </summary>
[RequireComponent(typeof(UIRoot))]
public class UIRatio : MonoBehaviour
{
    public int Width = 1280;
    public float AspectRatio = 1.78f;

    void OnEnable()
    {
        UIRoot Root = GetComponent<UIRoot>();
        float ar = Mathf.Round((float)Screen.width / Screen.height * 100) / 100;
        if (ar != AspectRatio)
        {
            int height = (int)(Width / ar);
            if (Mathf.Abs(Root.manualHeight - height) > 1)
                Root.manualHeight = height;
        }
    }
}
